/*
 * Copyright (C) 2011 Jesus Navalon i Pastor <jnavalon at redhermes dot net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * Connecting.java
 *
 * Created on 16/09/2011, 19:16:39
 */
package kuasar.plugin.deployer.gui.actions.infopns;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

/**
 *
 * @author Jesus Navalon i Pastor <jnavalon at redhermes dot net>
 */
public class pn_Connecting extends javax.swing.JPanel {
    private int currentFrame = 0;
    private Timer imageConnection = new Timer (50, new ActionListener ()
        {
        @Override
            public void actionPerformed(ActionEvent e)
            {
                currentFrame++;
                javax.swing.ImageIcon icon;
                try{
                    icon = new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/deployer/icons/animation/connection/connection" + currentFrame + ".png"));
                }catch(NullPointerException ex){
                    currentFrame=1;
                    icon =  new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/deployer/icons/animation/connection/connection" + currentFrame + ".png"));
                }
                lbl_Image.setIcon(icon);
             }
        }); 
    /** Creates new form Connecting */
    public pn_Connecting() {
        initComponents();
        imageConnection.start();
    }
    public void stopAnimation(){
        imageConnection.stop();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbl_Image = new javax.swing.JLabel();

        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(43, 184));

        lbl_Image.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_Image.setIcon(new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/deployer/icons/animation/connection/connection1.png"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbl_Image, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbl_Image, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lbl_Image;
    // End of variables declaration//GEN-END:variables
}
